package com.kgcx.system.service;

import com.kgcx.system.domain.Menu;
import com.kgcx.system.domain.SysRoleMenu;
import com.kgcx.system.mapper.MenuMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 吴刚林
 * @date 2017/12/5
 */
@Service
public class MenuService {
    @Autowired
    private MenuMapper menuMapper;
    @Autowired
    private SysRoleMenuService sysRoleMenuService;


    public List<String> getResUrlsByRoleId(Long roleId) {
        return menuMapper.getResUrlsByRoleId(roleId);
    }

    /**
     * 查询所有菜单
     *
     * @return
     */
    public List<Menu> queryMenuList() {
        return menuMapper.queryMenuList();
    }

    /**
     * 查询所有菜单
     *
     * @return
     */
    public List<Menu> queryMenuListByUser(Integer employeeId) {
        List<Menu> menuList = new ArrayList<>();
        List<SysRoleMenu> list = sysRoleMenuService.queryListByEmployeeId(employeeId);
        if (null != list && list.size() > 0) {
            menuList = menuMapper.queryMenuByIds(list);
        }
        return menuList;
    }


}
